package cocurrency.waitnotify;

/**
 * Created by luzl on 4/6/2017.
 */
public class WaitTest extends  Thread{
    private Lock lock;
    public WaitTest(Lock lock){
        this.lock=lock;
    }
    public void run(){
        synchronized (lock){
            System.out.println(Thread.currentThread().getName()+ " Hello, I am waiting!");
            try {
                lock.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+" count is : "+lock.getCount().intValue());
            System.out.println(Thread.currentThread().getName()+ " Wow, It's done");
        }
    }
}
